/*
 * @Author: xiaozhuang-c-language 3535851673@qq.com
 * @Date: 2025-08-26 14:05:03
 * @LastEditors: xiaozhuang-c-language 3535851673@qq.com
 * @LastEditTime: 2025-08-26 14:51:00
 * @FilePath: /zhuang/protobuf_test/fast_start/test.cc
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include<iostream>
#include<vector>
#include"contact.pb.h"
using namespace std;

int main()
{
    string people_str;
    //1.序列化
    {
       contact::PeopleInfo people;
       people.set_name("小明");
       people.set_age(18);
       people.SerializeToString(&people_str);
       cout << "序列化结果:" << people_str << endl;
       cout << "lenth:" << people.mutable_name()->length() << endl;
    }
    //2.反序列化
    {
        contact::PeopleInfo people;
        people.ParseFromString(people_str);
        cout << "反序列化结果:" << endl;
        cout << "姓名:" << people.name() << endl;
        cout << "年龄:" << people.age() << endl;
    }
    return 0;
}